package com.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {

    // ↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "9021000123629282";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAO2k2guc2TL1r49Fji7+b27n1oze0tHzP77BQhzJdWpNk+g4M1G9nQeTDYO1yTvmz7qIc/7VBqxpRj4quYDyeBfe1cq30rbUnWnNiwfchtB5RWoUXKtmD+TYru6ndkaZquTKIL2VsVWufPie5PZBID8z5rv+m5CyiBxQaOOXauIxDvNFzxsfBh5diPM1Qhly3y7MwLSfwEwohE1XnZMoVc5xIgtTtSJkkVLaYTZTwgfl3mZyzu2t0zdgKMoDr7CeS0CTxcHxybSAAxZVmhBVCbZhr9nuf/XjyXgAVzofamyOxDXXXPAcAm45XAS3rYCghOIpWI37HIeHne5L948ypAgMBAAECggEAaAxM9c9HvraL6JRFXYmSYuvqOxdB5x2gPLTXErBwvHD3MjL33Y8uCdHcxm/KmzrbwBU8c11E/NDSHSXkuFMcPHjJIvC3l9avLAxnndWXKkDVbNuPLFo3fq9jNh8i2McLCoPVLc2PdVTma6LqZpM+lEpF3r8Rb6CrWpl1xUUvtMVt8WbTcoc54mNXiO7dq8TP18Fs6XmLqrh3WH0TplxW8rCC8l5bu+D2bwZ1Hvz3oZvXwLVPWA8hbKifdXGL5iSQRBLjj+wazF/vD/2HO1umhDBYmzcuLTD//eBwsC4Qh6TPrjHBseVQ+I4DPK4QCLbbbHpe55M2Q6lmY3WAPYdYEQKBgQC4FrukuRo1UzSYbR3o5i5DV6lV1x+0e6hyS7StqIxeZGFqb9MzGRwYK2gOUFRTxuAWD4VQa5eF9LxBaCCXCLWOolteRf5yoy6SEM91Dhh5FW9AXLUgC0Qha5iOZPNLNVelJwGOGEi9JVrLYYspxMigovaq5+M4N7epxtBbsx11zQKBgQCyUuNQQqygtiKdTobDb4lG8q8iu1IfpQTdpKOoPk5nRumzPZ4EThynfD1OtShC6EnE4eem0uZerCa7Pnw41LJNvWMnQZIAI/gcvRtszbxqX+JYmdNh3cvp8r/spl9Y3gZzJibOmnz7e7x8N4m9soKAJS7MJAp+PuLWKT+C5cbWTQKBgBN/5PR33vzTCXkz5b0r1K6xdHBxTxxxFNC2kDbs6aF+BIufuMFq4Xz17BnIDIarREVR848nNm+sEtziyMD23TR0ojUEOQWvn1k9ipwdmB4LVTN+Hnl8eAUKPqimrNbEmboWvaVtkRboBAwTEwijnZTWbkaANaNY042aT6vG91HpAoGAAMaFgIrZr1U7b02xHlZ01V8mzdLct5CDJeeaYpfqxV40k/f3oPMqArxyk84L38ac04Nb+4i9Qboj7PqHlcOvBtGFBd2uIdwGLzHPVbjLUfcax+HbXniVc23/0aqjjYJhqsyGrK1VT86o8i1XpwCIur/upSqe9Q+W8vF4+ju/kp0CgYAg17g7qUif07uo99kTi3oo9+3vTy+5Ro+ZrSVM2B0THlDDjFDjhG8hNkjI360GucjxYfAe4Nj2FnawYLKWgd7t99YZUpvX6Cv9XqsxslzKRNKKisBsMCqsFYJFDN3a3jc3UleVmazKe9OLc4tlPbyEAoEi0fomFUHrM7vfDmmF/Q==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm
    // 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAms7OT8ogi34JFLJ8oAniM6ngGfgMEkiYUB4haRwfWwcLnnUInbVnLokDHgk1DKrBaYLGOCZzhVOJbsKYywZPoenPjS/0vToqCyblei084scidGTixupynpKcgWKahiupsc/1v7w5EJswvXRdzhtiSizIa8TkvZ0ir3QafwtYbUMdZD2KL2FLht9gdqbsQCLsuwdiWh64vmwmGROdgVeVtFakAPnbhid4FXDg3nq+MRnWzvzIz8uLZjPd9G2z77b8RBRagVyCODshsPV+mmK1gt2C61V1tlZl1N9pTMhtjh9zHSVYDpqvDOZIaYdBc4mmi8jC5nawNTIFr4RIJQgZ+wIDAQAB";

    // 服务器异步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://localhost:9898/notify_url.jsp";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://localhost:9898/return_url.jsp";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "D:\\";

    // ↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord
     *            要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_"
                    + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
          //  writer.write();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
